package com.csd.action.teacher;

import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.serviceImpl.ChangeRecordService;
import com.csd.vo.UserVO;

/**
 * 
 * 教师对项目变更的审批Action类
 * 
 * @author 尹华彬
 * @version 1.0
 * 
 * <br>
 *          修订时间：2009-12-17 <br>
 *          修改原因：创建文件 <br>
 *          修改人：尹华彬
 * 
 * <br>
 * 
 */

public class TeacherChangeResultAction {

	// 老师评价内容
	private String advice;
	// 项目变更的老师审批结果
	private String changeResult;
	//变更服务类    
	private ChangeRecordService changeRecordService;


	private Integer changeRecordID;

	public Integer getChangeRecordID() {
		return changeRecordID;
	}

	public void setChangeRecordID(Integer changeRecordID) {
		this.changeRecordID = changeRecordID;
	}

	public ChangeRecordService getChangeRecordService() {
		return changeRecordService;
	}

	public void setChangeRecordService(ChangeRecordService changeRecordService) {
		this.changeRecordService = changeRecordService;
	}

	
	public String getAdvice() {
		return advice;
	}

	public void setAdvice(String advice) {
		this.advice = advice;
	}

	public String getChangeResult() {
		return changeResult;
	}

	public void setChangeResult(String changeResult) {
		this.changeResult = changeResult;
	}

	public String execute() {
		// 通过变更ID，完成项目变更的审批
		String result = ActionResult.fail;
		Integer teacherID = null;
		
		// 通过session获得teacherID.
		try {
			HttpSession httpSession = ServletActionContext.getRequest().getSession();
			UserVO value = (UserVO)httpSession.getAttribute(IConstant.userVO);
			if(value == null){
				throw  new Exception("用户未登录异常");
			}
			teacherID = value.getUserID();
		} catch (Exception e) {
			e.printStackTrace();
			return result;
		}
	    
		if(teacherID == null)
			return result;
		//更新变更
		changeRecordService.updateChangeRecord(changeRecordID, advice, changeResult);
		result = ActionResult.success;
		
		return result;
	}

}
